home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
FromTheMag
/
JW FLV MEDIA PLAYER 4.2
/
mediaplayer.exe
/
player.swf
/
scripts
/
com
/
jeroenwijering
/
utils
/
Strings.as
< prev
Wrap
Text File
|
2008-11-04
|
4KB
|
129 lines
package com.jeroenwijering.utils
{
public class Strings
{
public function Strings()
{
super();
}
public static function serialize(param1:String) : Object
{
if(param1 == "true")
{
return true;
}
if(param1 == "false")
{
return false;
}
if(isNaN(Number(param1)) || param1.length == 6)
{
return Strings.decode(param1);
}
return Number(param1);
}
public static function replace(param1:String, param2:String, param3:String) : String
{
var _loc4_:Number = NaN;
var _loc5_:Number = NaN;
_loc4_ = param1.indexOf(param2);
_loc5_ = 0;
while(_loc4_ > -1)
{
param1 = param1.substr(0,param1.indexOf(param2)) + param3 + param1.substr(param1.indexOf(param2) + param2.length);
_loc4_ = param1.indexOf(param2,_loc4_ - param2.length + param3.length);
_loc5_++;
}
return param1;
}
public static function digits(param1:Number) : String
{
var _loc2_:Number = NaN;
var _loc3_:Number = NaN;
_loc2_ = Math.floor(param1 / 60);
_loc3_ = Math.floor(param1 % 60);
return Strings.zero(_loc2_) + ":" + Strings.zero(_loc3_);
}
public static function zero(param1:Number) : String
{
if(param1 < 10)
{
return "0" + param1;
}
return "" + param1;
}
public static function strip(param1:String) : String
{
var _loc2_:Array = null;
var _loc3_:Number = NaN;
var _loc4_:Number = NaN;
_loc2_ = param1.split("\n");
param1 = _loc2_.join("");
_loc2_ = param1.split("\r");
param1 = _loc2_.join("");
_loc3_ = param1.indexOf("<");
while(_loc3_ != -1)
{
if((_loc4_ = param1.indexOf(">",_loc3_ + 1)) == -1)
{
_loc4_ = param1.length - 1;
}
param1 = param1.substr(0,_loc3_) + " " + param1.substr(_loc4_ + 1,param1.length);
_loc3_ = param1.indexOf("<",_loc3_);
}
return param1;
}
public static function decode(param1:String) : String
{
if(param1.indexOf("asfunction") == -1)
{
return unescape(param1);
}
return "";
}
public static function seconds(param1:String) : Number
{
var _loc2_:Array = null;
var _loc3_:Number = NaN;
param1 = Strings.replace(param1,",",".");
_loc2_ = param1.split(":");
_loc3_ = 0;
if(param1.substr(-1) == "s")
{
_loc3_ = Number(param1.substr(0,param1.length - 1));
}
else if(param1.substr(-1) == "m")
{
_loc3_ = Number(param1.substr(0,param1.length - 1)) * 60;
}
else if(param1.substr(-1) == "h")
{
_loc3_ = Number(param1.substr(0,param1.length - 1)) * 3600;
}
else if(_loc2_.length > 1)
{
_loc3_ = Number(_loc2_[_loc2_.length - 1]);
_loc3_ += Number(_loc2_[_loc2_.length - 2]) * 60;
if(_loc2_.length == 3)
{
_loc3_ += Number(_loc2_[_loc2_.length - 3]) * 3600;
}
}
else
{
_loc3_ = Number(param1);
}
return _loc3_;
}
}
}